package top.csmcool.musicapi.controller;

/*
 * @description 用户登录退出接口
 * @date 2025/1/27
 * @author shijin
 * @version 1.0
 */

import cn.dev33.satoken.stp.SaTokenInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.csmcool.musicapi.domain.UserPlatformBindInfo;
import top.csmcool.musicapi.domain.Users;
import top.csmcool.musicapi.model.playlist.PlayListMusicInfo;
import top.csmcool.musicapi.model.result.Request;
import top.csmcool.musicapi.model.result.Result;
import top.csmcool.musicapi.model.system.PlatformInfo;
import top.csmcool.musicapi.model.user.UserLogin;
import top.csmcool.musicapi.service.UserService;

import java.util.List;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@CrossOrigin(origins = "*")
public class UserController {

    private final UserService userService;

    @PostMapping("/login")
    public Result<SaTokenInfo> login(@RequestBody Request<UserLogin> requestRequest) {
        return userService.login(requestRequest);
    }

    @PostMapping("/adminLogin")
    public Result<SaTokenInfo> adminLogin(@RequestBody Request<UserLogin> requestRequest) {
        return userService.adminLogin(requestRequest);
    }

    @PostMapping("/userInfo")
    public Result<Users> getUserInfo() {
        return userService.getUserInfo();
    }

    @PostMapping("/paltforms")
    public Result<List<PlatformInfo>> getPaltforms() {
        return userService.getUserPlatform();
    }

    @PostMapping("/getPlatformInfos")
    public Result<List<UserPlatformBindInfo>> getPlatformInfos() {
        return userService.getPlatformInfos();
    }

    @PostMapping("/updateUserInfo")
    public Result<Users> updateUserInfo(@RequestBody Request<Users> request) {
        return userService.updateUserInfo(request);
    }

    @PostMapping("/updatePlatformInfo")
    public Result<UserPlatformBindInfo> updatePlatformInfo(@RequestBody Request<UserPlatformBindInfo> request) {
        return userService.updatePlatformInfo(request);
    }
}
